#include "Computer.h"
#include <iostream>

using std::cout;
using std::endl;

#if 0
Computer gComputer("huawei", 8000);//全局对象

void test()
{
    Computer com("ThinkPad", 5300);//栈对象
    cout << "com = ";
    com.print();

    /* com.~Computer();//析构函数可以显示调用，但是不建议显示调用 */
    /* com.print(); */

    cout << endl << endl;
    int *pInt = new int(10);

    Computer *pc = new Computer("xiaomi", 6000);//堆对象
    pc->print();

    delete pc;//堆对象需要显示的使用delete，否则析构函数调用不到
    pc = nullptr;

    delete pInt;
    pInt = nullptr;

}

int test2()
{
    gComputer.print();
    cout << endl;
    cout << "begin main..." << endl;
    test();
    cout << "finish main..." << endl;

}
#endif

void test3()
{
    Computer com1("ThinkPad", 5300);
    cout << "com1 = ";
    com1.print();

    cout << endl;
    Computer com2 = com1;
    cout << "com2 = ";
    com2.print();

    cout << endl;
    com1.setBrand("huawei");
}

int main(int argc, char **argv)
{
    test3();
    return 0;
}
